/* experimental tests. Table 4 */
/* MODEL I: individual citizens/procedure */

proc glm data=citizens plots(only)=diagnostics(unpack); 
 class vignette(ref='1'); 
 model nmeanprocedure=vignette/solution effectsize alpha=0.05;  
 /*contrast reported in the paper */
 lsmeans vignette / e;
 contrast 'vignette 2 tgo vignette 1'       vignette  1  0  0  0 -1/e;
 contrast 'vignette 4 tgo vignette 1'       vignette  0  0  1  0 -1/e;
 contrast 'vignette 4 tgo vignette 5'       vignette  0  0  1 -1  0/e;
 contrast 'vignette 4 tgo vignette 3'       vignette  0 -1  1  0  0/e;
 contrast 'vignette 4 tgo vignette 2'       vignette -1  0  1  0  0/e;
 contrast 'vignette 4 tgo vignette 2 and 3' vignette  1  1 -2  0  0/e;
 contrast 'vignette 3 tgo vignette 2'       vignette -1  1  0  0  0/e;
 means vignette/hovtest;
 output out=modelI predicted=Procedure_Acceptance_Predicted lcl=lcl lclm=lclm ucl=ucl uclm=uclm r=residuals student=student; 

/* predicted values reported in the paper */
proc means data=modelI mean min max;
 var Procedure_Acceptance_Predicted lclm uclm;
 class vignette;

/* MODEL II: company leaders/procedure */
proc glm data=companies plots(only)=diagnostics(unpack); 
 class vignette(ref='1'); 
 model nmeanprocedure=vignette/solution effectsize;  
 /*contrast reported in the paper */
 lsmeans vignette / e  adjust=tukey;;
*means vignette/alpha=0.05 lsd tukey;
 contrast 'vignette 2 tgo vignette 3'       vignette  1 -1  0  0  0/e;
 contrast 'vignette 4 tgo vignette 5'       vignette  0  0  1 -1  0/e;
 contrast 'vignette 4 tgo vignette 1'       vignette  0  0  1  0 -1/e;
 contrast 'vignette 4 tgo vignette 3'       vignette  0 -1  1  0  0/e;
 contrast 'vignette 4 tgo vignette 2'       vignette -1  0  1  0  0/e;
 contrast 'vignette 4 tgo vignette 2 and 3' vignette  1  1 -2  0  0/e;
 contrast 'vignette 3 tgo vignette 1'       vignette  0  1  0  0 -1/e;
 means vignette/hovtest;
 output out=modelI predicted=Procedure_Acceptance_Predicted lcl=lcl lclm=lclm ucl=ucl uclm=uclm r=residuals student=student; 

/* predicted values reported in the paper */
proc means data=modelI mean min max;
 var Procedure_Acceptance_Predicted lclm uclm;
 class vignette;

/* MODEL III: individual citizens/decision */
proc glm data=citizens plots(only)=diagnostics(unpack);
 class vignette(ref='1'); 
 model nmeandecision=vignette/solution effectsize;  
 lsmeans vignette / e;
 means vignette/hovtest;
 contrast 'vignette 4 tgo vignette 1'            vignette  0  1  0  0 -1/e;  /*check for contrast*/
 output out=modelI predicted=Procedure_Acceptance_Predicted lcl=lcl lclm=lclm ucl=ucl uclm=uclm r=residuals ; 

/* MODEL IV: company leaders/decision */
proc glm data=companies plots(only)=diagnostics(unpack);; 
 class vignette(ref='1'); 
 model nmeandecision=vignette/solution;  
 lsmeans vignette / e;
 means vignette/hovtest;
 contrast 'vignette 4 tgo vignette 1'            vignette  1  0  0  0 -1/e;  /*check for contrast*/
 output out=modelI predicted=Procedure_Acceptance_Predicted lcl=lcl lclm=lclm ucl=ucl uclm=uclm; 

/* interaction models. Table 5 */
/* MODEL V: indvidual citizens, non-interactive */
proc glm data=citizens plots(only)=diagnostics(unpack);
 class vignette(ref='1') id; 
 model nmeandecision =nmeanprocedure nLeft_Right/solution clparm;
 lsmeans nmeanprocedure nLeft_Right/ e;
 output out=predict predicted=Decision_Acceptance_Predicted lcl=lcl lclm=lclm ucl=ucl uclm=uclm; 

/* MODEL VI: indvidual citizens, interactive */
proc glm data=citizens plots(only)=diagnostics(unpack); 
 class vignette(ref='1'); 
 model nmeandecision =nmeanprocedure nLeft_Right nLeft_Right*nmeanprocedure/solution effectsize clparm;
 output out=predict predicted=Decision_Acceptance_Predicted lcl=lcl lclm=lclm ucl=ucl uclm=uclm; 

/* creating figure 1 */
data predict;
 set predict;
attrib acceproc length=$25;
if meanprocedure lt 3                             then acceproc = 'Low';
else if meanprocedure ge 3 and meanprocedure le 4 then acceproc = 'Medium';
else if meanprocedure gt 4                        then acceproc = 'High';

label Decision_Acceptance_Predicted='Predicted Decision Acceptance';
label Left_Right                   ='Left-right Orientation';
label meanprocedure                ='Procedure Acceptance'; 
label acceproc                     ='Procedure Acceptance'; 

proc means data=predict mean min max; var nLeft_Right; run;  
proc means data=predict mean min max; var Decision_Acceptance_Predicted lclm uclm; where acceproc='Low' and nLeft_Right eq 0;
proc means data=predict mean min max; var Decision_Acceptance_Predicted lclm uclm; where acceproc='Low' and nLeft_Right eq 1;

proc means data=predict mean min max; var Decision_Acceptance_Predicted lclm uclm; where acceproc='High' and nLeft_Right eq 0;
proc means data=predict mean min max; var Decision_Acceptance_Predicted lclm uclm; where acceproc='High' and nLeft_Right eq 1;


proc sgplot data=predict noautolegend;
  reg  x=nLeft_Right y=Decision_Acceptance_Predicted/degree=1 group=acceproc clm='95% Confidence Limits';  
  yaxis label='Predicted Decision Acceptance'; 
  Xaxis label='Left-Right Orientation'; 
  keylegend / location=outside position=bottom across=1;

/* MODEL VII: company leaders, non-interactive */
proc glm data=companies plots(only)=diagnostics(unpack); 
 class vignette(ref='1'); 
 model nmeandecision =nmeanprocedure nLeft_Right/solution clparm;
 output out=predict predicted=Decision_Acceptance_Predicted lcl=lcl lclm=lclm ucl=ucl uclm=uclm; 
 store contcont;

/* predicted values reported in the paper */
proc means data=predict mean min max;
 var Decision_Acceptance_Predicted nmeanprocedure nLeft_Right lcl lclm ucl uclm;

proc plm restore=contcont; estimate 'pred nmeandecision, nmeanprocedure=0, nLeft_Right=0.52' intercept 1 nmeanprocedure 0 nLeft_Right 0.52/e alpha=0.05 lower upper; 
proc plm restore=contcont; estimate 'pred nmeandecision, nmeanprocedure=1, nLeft_Right=0.52' intercept 1 nmeanprocedure 1 nLeft_Right 0.52/e alpha=0.05 lower upper; 

/* MODEL VIII: company leaders, interactive */
proc glm data=companies plots(only)=diagnostics(unpack); ;
 class vignette(ref='1'); 
 model nmeandecision =nmeanprocedure nLeft_Right nLeft_Right*nmeanprocedure/solution;
 output out=predict predicted=Decision_Acceptance_Predicted lcl=lcl lclm=lclm ucl=ucl uclm=uclm; 
 store contcont;
run;

